﻿using PanhuaWin.系统管理;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PanhuaWin.工厂.车间.报工
{
    public partial class Form退火报工维护 : UIPage
    {
        string 工厂guid1;
        string 部门编号1;
        string FormGuid;
        int 开始行;
        int 结束行;
        string 部门guid;
        string tempguid;
        string 退火原卷guid;
        string FormWorkType = "退火";
        decimal 卷的总重量;
        string 用来保存的原卷号;

        public Form退火报工维护()
        {
            InitializeComponent();
        }

        private void Form退火报工维护_Load(object sender, EventArgs e)
        {
            tempguid = Guid.NewGuid().ToString();
            this.uiTextBox工厂名称.Text = pub.全局工厂名称;

            this.uiDatePicker报工日期.Value = DateTime.Today;
            pub.ListMaterial(pub.全局工厂编号, FormWorkType, this.uiComboBox新材质);
            pub.ListWorkLine(pub.全局工厂编号, FormWorkType, this.uiComboBox产线);
            pub.ListWorkType(pub.全局工厂编号, FormWorkType, this.uiComboBox去向);
            pub.ListQualityStandard(FormWorkType, this.uiComboBox执行标准);
            pub.ListRank(pub.全局工厂编号, this.uiComboBox质量等级);
            pub.ListDayShift(pub.全局工厂编号, this.uiComboBoxDayShift);
            pub.List品名(this.uiComboBox品名, FormWorkType, this.uiComboBox质量等级.SelectedText);
            pub.ListFaceDone(FormWorkType, this.uiComboBox表面处理);
            pub.ListWareHouse(this.uiComboBox仓库, pub.全局工厂guid);
            清理自己mac的Temp_退火报工原卷占用();
            string 当前班组 = pub.Get员工所属班组(pub.sys_user.UserTrueName);
            if (当前班组 == "")
            {
                pub.ListWorkTeam(pub.全局工厂编号, this.uiComboBox产线.SelectedValue.ToString(), this.uiComboBoxWorkTeam);
            }
            else
            {
                this.uiComboBoxWorkTeam.Items.Add(当前班组);
                this.uiComboBoxWorkTeam.SelectedIndex = 0;
            }

            uiComboBox包装.Items.Add("精包");
            uiComboBox包装.Items.Add("简包");
            uiComboBox包装.Items.Add("普包");
            uiComboBox包装.Items.Add("裸包");
            uiComboBox包装.Items.Add("中性包");
            uiComboBox包装.Items.Add("无");
            uiComboBox包装.SelectedIndex = 2;
        }

        private void 清理自己mac的Temp_退火报工原卷占用()
        {
            string sql;
            sql = "delete Temp_退火报工原卷占用 where mac='" + pub.getMac() + "' ";
            pub.ExecuteSql(pub.ConnectionString, sql, "清理自己mac的Temp_退火报工原卷占用,Temp_退火报工原卷占用");
        }
        private void 塞入自己的tempguid的数据(string tempguid, string volumeCodeNew)
        {
            string sql;
            sql = "insert into Temp_退火报工原卷占用(guid, OriginalVolumeNew, MAC, 时间 ) values('" + tempguid + "','" + volumeCodeNew + "','" + pub.getMac() + "' ,getdate()) ";
            pub.ExecuteSql(pub.ConnectionString, sql, "塞入自己的tempguid的数据,Temp_退火报工原卷占用");
        }

        private void 删除自己的tempguid的数据(string tempguid)
        {
            string sql;
            sql = "delete Temp_退火报工原卷占用 where mac='" + pub.getMac() + "' ";

            pub.ExecuteSql(pub.ConnectionString, sql, "删除自己的tempguid的数据,Temp_退火报工原卷占用");
        }

        private void uiComboBox产线_SelectedIndexChanged(object sender, EventArgs e)
        {
            string workLineCode;
            if (this.uiComboBox产线.SelectedValue.ToString() != "")
            {
                this.uiTextBox仓库.Text = pub.根据产线获得仓库(this.uiComboBox产线.SelectedText);
                this.uiComboBox仓库.SelectedValue = pub.根据产线获得仓库编号(this.uiComboBox产线.SelectedText);
                pub.ListWorkType(pub.全局工厂编号, FormWorkType, this.uiComboBox去向);
            }
        }
        private void uiTextBox新厚度_TextChanged(object sender, EventArgs e)
        {
            SetSize();
            刷新理算米数();
            刷新理算厚度();
        }

        private void 刷新理算米数()
        {
            double 手填重量;

            手填重量 = pub.Todouble(this.uiTextBox新重量.Text);
            double 手填宽度;
            手填宽度 = pub.Todouble(this.uiTextBox新宽度.Text);
            double 手填厚度;
            手填厚度 = pub.Todouble(this.uiTextBox新厚度.Text);
            //decimal 手填米数;
            //手填米数 = pub.Todecimal(this.uiTextBox新米数.Text);
            if (手填重量 > 0 && 手填宽度 > 0 && 手填厚度 > 0)
            {
                this.uiTextBox理算米数.Text = Math.Round((手填重量 / (手填宽度 / 1000) / 手填厚度 / 7.85), 4).ToString();
            }
            else
            {
                this.uiTextBox理算米数.Text = "";
            }
        }

        private void 刷新理算厚度()
        {
            double 手填重量;

            手填重量 = pub.Todouble(this.uiTextBox新重量.Text);
            double 手填宽度;
            手填宽度 = pub.Todouble(this.uiTextBox新宽度.Text);
            //double 手填厚度;
            //手填厚度 = pub.Todouble(this.uiTextBox新宽度.Text);
            double 手填米数;
            手填米数 = pub.Todouble(this.uiTextBox新米数.Text);
            if (手填重量 > 0 && 手填宽度 > 0 && 手填米数 > 0)
            {
                this.uiTextBox理算厚度.Text = Math.Round((手填重量 / (手填宽度 / 1000) / 手填米数 / 7.85), 4).ToString();
            }
            else
            {
                this.uiTextBox理算厚度.Text = "";
            }
        }

        private void uiTextBox新宽度_TextChanged(object sender, EventArgs e)
        {
            SetSize();
            刷新理算米数();
            刷新理算厚度();
        }

        private void SetSize()
        {
            this.uiTextBox新规格.Text = pub.Todecimal(this.uiTextBox新厚度.Text, 3) + "*" + pub.ToInt(this.uiTextBox成品宽度.Text) + "*C";
        }

        private void uiCheckBox拆成多卷_CheckedChanged(object sender, EventArgs e)
        {
            if (this.uiCheckBox拆成多卷.Checked)
            {
                this.numericUpDown1.Visible = true;
            }
            else
            {
                this.numericUpDown1.Visible = false;
            }
        }

        private void uiButton添加产出卷_Click(object sender, EventArgs e)
        {
            if (pub.Todecimal(this.uiTextBox卷重量1.Text) * (pub.查询超重比例(FormWorkType)) < 卷的总重量 + pub.Todecimal(this.uiTextBox新重量.Text))
            {
                MessageBox.Show("产出卷的重量超过了投入卷重量,不能单卷报工。", "提示", MessageBoxButtons.OK);
                return;
            }
            if (this.uiCheckBox拆成多卷.Checked == false)
            {
                //单卷
                //已经存在的就不能再次点击添加了
                if (!pub.Is退火报工原始卷被关闭(this.uiTextBox原料卷号.Text))
                {
                    string sql;
                    List<Bus_FireOutput> Bus_FireOriginals = pub.Get退火产出卷信息All(this.uiTextBox原料卷号.Text);
                    if (Bus_FireOriginals != null)
                    {
                        MessageBox.Show("这个卷已经有产出卷了,不能单卷报工。", "提示", MessageBoxButtons.OK);
                        return;
                    }
                    //if (MessageBox.Show("这卷不再分拆会自动关闭，是否确认?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    //{
                    单卷报工();
                    //}
                }
                else
                {
                    MessageBox.Show("这个卷已经被关闭了，不能再次报工了，如需要再次报工，请联系管理员处理。", "提示", MessageBoxButtons.OK);
                    return;
                }

            }
            else
            {
                //单卷
                //已经存在的就不能再次点击添加了
                List<Bus_FireOutput> Bus_FireOriginals = pub.Get退火产出卷信息All(this.uiTextBox原料卷号.Text);

                if (Bus_FireOriginals != null)
                {
                    bool s = false;
                    foreach (Bus_FireOutput Bus_FireOriginal in Bus_FireOriginals)
                    {
                        if (this.uiTextBox原料卷号.Text.Replace("PHY", "") == Bus_FireOriginal.OutputVolumeNew.Replace("PHT", ""))
                        {
                            s = true;
                        }
                    }
                    if (s)
                    {
                        MessageBox.Show("这个卷已经有产出单卷了,不能多卷报工。", "提示", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (!pub.Is退火报工原始卷被关闭(this.uiTextBox原料卷号.Text))
                {
                    多卷报工();
                }
                else
                {
                    MessageBox.Show("这个卷已经被关闭了，不能再次报工了，如需要强制报工，请联系管理员处理。", "提示", MessageBoxButtons.OK);
                    return;
                }

            }
        }

        private void 多卷报工()
        {
            if (退火原卷guid == "" || this.uiTextBox原料卷号.Text == "")
            {
                MessageBox.Show("没有选择投入卷号", "提示", MessageBoxButtons.OK);
                return;
            }
            string sql;
            //在退火卷分卷时补0，比如01,02
            string 新卷号 = this.uiTextBox前缀.Text + this.uiTextBox产出卷号.Text + this.numericUpDown1.Value.ToString().PadLeft(2, '/');

            Bus_FireOutput Bus_FireOutput = new Bus_FireOutput();
            Bus_FireOutput.Creator = pub.sys_user.UserName;
            Bus_FireOutput.OutputDate = this.uiDatePicker报工日期.Value;
            if (this.uiComboBox去向.SelectedText == "")
            {
                MessageBox.Show("去向不能为空", "提示", MessageBoxButtons.OK);
                return;

            }
            if (pub.Get退火产出卷信息(新卷号) != null)
            {
                MessageBox.Show("产出卷号已经存在了，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.OutputNext = this.uiComboBox去向.SelectedText;
            Bus_FireOutput.WorkLineName = this.uiComboBox产线.SelectedText;
            if (Bus_FireOutput.WorkLineName == "")
            {
                MessageBox.Show("产线不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.WorkLineCode = this.uiComboBox产线.SelectedValue.ToString();
            Bus_FireOutput.DayShiftCode = this.uiComboBoxDayShift.SelectedValue.ToString();
            Bus_FireOutput.DayShiftName = this.uiComboBoxDayShift.SelectedText;

            Bus_FireOutput.WorkTeamCode = this.uiComboBoxWorkTeam.SelectedText;
            Bus_FireOutput.WorkTeamName = this.uiComboBoxWorkTeam.SelectedText;
            if (Bus_FireOutput.WorkTeamName == "")
            {
                MessageBox.Show("班组不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            //Bus_FireOutput.DepartCode = this.uiTextBox部门1.Text;
            //Bus_FireOutput.DepartName = this.uiTextBox部门名称1.Text;
            if (Bus_FireOutput.DepartName == "")
            {
                MessageBox.Show("部门不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.guid = Guid.Parse(退火原卷guid);
            Bus_FireOutput.OutputGuid = Guid.NewGuid();
            Bus_FireOutput.OutputMaterial = this.uiComboBox新材质.SelectedText;
            Bus_FireOutput.OutputQualityGrade = this.uiComboBox质量等级.SelectedText;
            Bus_FireOutput.OutputQualityInformation = this.uiTextBox质量信息.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputSize = this.uiTextBox新规格.Text;
            Bus_FireOutput.OutputThick = pub.Todecimal(uiTextBox新厚度.Text);
            Bus_FireOutput.OutputWidth = uiTextBox新宽度.Text;
            Bus_FireOutput.OutputWeight = pub.Todecimal(uiTextBox新重量.Text);
            if (Bus_FireOutput.OutputWeight == 0)
            {
                MessageBox.Show("重量不能为0", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.OutputMeter = pub.Todecimal(uiTextBox新米数.Text);
            if (Bus_FireOutput.OutputMeter == 0)
            {
                MessageBox.Show("米数不能为0", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.InventoryName = this.uiComboBox品名.Text;
            Bus_FireOutput.OutputAddress = this.uiTextBox产地1.Text;
            Bus_FireOutput.Customer = this.uiTextBox客户.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputKangla = this.uiTextBox抗拉.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputQufu = this.uiTextBox屈服.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputYanshenlv = this.uiTextBox延伸率.Text.Trim().Replace("--", "");
            Bus_FireOutput.FaceDone = this.uiComboBox表面处理.Text.Trim().Replace("--", "");
            Bus_FireOutput.Package = this.uiComboBox包装.Text;

            sql = " insert into Bus_FireOutput(OutputGuid, guid,OutputDate, VolumeCodeNew,Row, OutputVolumeNew, OutputSize, OutputThick, OutputWidth, OutputMaterial, OutputWeight, OutputMeter,";
            sql += " OutputQualityGrade, OutputQualityInformation, OutputEndStatus, OutputNext, PrintTimes, DepartCode, DepartName, ";
            sql += " WorkLineCode, WorkLineName, WorkTeamCode, WorkTeamName, DayShiftCode, DayShiftName, CreateID, Creator,";
            sql += " CreateDate,OutputAddress,Customer,OutputKangla,OutputQufu,OutputYanshenlv,FaceDone,Package,InventoryName,LisuanThick,LisuanMeter,Area)";
            sql += " values(newid(),'" + 退火原卷guid + "','" + Bus_FireOutput.OutputDate?.ToString("yyyy-MM-dd") + "','" + this.uiTextBox原料卷号.Text.Trim().Replace("--", "") + "','" + this.numericUpDown1.Value.ToString() + "','" + 新卷号 + "','" + Bus_FireOutput.OutputSize + "','" + Bus_FireOutput.OutputThick + "','" + Bus_FireOutput.OutputWidth + "',";
            sql += " '" + Bus_FireOutput.OutputMaterial + "','" + Bus_FireOutput.OutputWeight + "','" + Bus_FireOutput.OutputMeter + "','" + Bus_FireOutput.OutputQualityGrade + "','" + Bus_FireOutput.OutputQualityInformation + "',";
            sql += "  '','" + Bus_FireOutput.OutputNext + "',0,'" + Bus_FireOutput.DepartCode + "','" + Bus_FireOutput.DepartName + "',";
            sql += " '" + Bus_FireOutput.WorkLineCode + "','" + Bus_FireOutput.WorkLineName + "','" + Bus_FireOutput.WorkTeamCode + "','" + Bus_FireOutput.WorkTeamName + "',";
            sql += " '" + Bus_FireOutput.DayShiftCode + "','" + Bus_FireOutput.DayShiftName + "','" + pub.sys_user.User_Id + "','" + pub.sys_user.UserTrueName + "',";
            sql += " getdate(),'" + Bus_FireOutput.OutputAddress + "','" + Bus_FireOutput.Customer + "','" + Bus_FireOutput.OutputKangla + "',";
            sql += " '" + Bus_FireOutput.OutputQufu + "','" + Bus_FireOutput.OutputYanshenlv + "','" + Bus_FireOutput.FaceDone + "','" + Bus_FireOutput.Package + "','" + Bus_FireOutput.InventoryName + "','" + uiTextBox理算厚度.Text + "','" + uiTextBox理算米数.Text + "','" + uiTextBox面积.Text.Trim() + "') ";

            if (pub.ExecuteSql(pub.ConnectionString, sql, "多卷退火报工塞入Bus_FireOutput") > 0)
            {
                MessageBox.Show("多卷退火报工成功", "提示", MessageBoxButtons.OK);
                //不用自动关闭
                //sql = "update Bus_PicklingOriginal set IsClosed='Y' , ColseUserId='" + pub.sys_user.User_Id + "',ColseUserName='" + pub.sys_user.UserTrueName + "',CloseDate=getdate() where guid='" + 退火原卷guid + "'";
                //pub.ExecuteSql(pub.ConnectionString, sql, "单卷退火报工成功，自动关闭原卷的状态");
                //显示卷信息到表格上
                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                return;
            }
        }

        private void 单卷报工()
        {
            if (退火原卷guid == "" || this.uiTextBox原料卷号.Text == "")
            {
                MessageBox.Show("没有选择投入卷号", "提示", MessageBoxButtons.OK);
                return;
            }
            string sql;
            string 新卷号 = this.uiTextBox前缀.Text + this.uiTextBox产出卷号.Text;
            Bus_FireOutput Bus_FireOutput = new Bus_FireOutput();
            Bus_FireOutput.Creator = pub.sys_user.UserName;
            Bus_FireOutput.OutputDate = this.uiDatePicker报工日期.Value;
            if (this.uiComboBox去向.SelectedText == "")
            {
                MessageBox.Show("去向不能为空", "提示", MessageBoxButtons.OK);
                return;

            }
            Bus_FireOutput.OutputNext = this.uiComboBox去向.SelectedText;
            Bus_FireOutput.WorkLineName = this.uiComboBox产线.SelectedText;
            if (Bus_FireOutput.WorkLineName == "")
            {
                MessageBox.Show("产线不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.WorkLineCode = this.uiComboBox产线.SelectedValue.ToString();
            Bus_FireOutput.DayShiftCode = this.uiComboBoxDayShift.SelectedValue.ToString();
            Bus_FireOutput.DayShiftName = this.uiComboBoxDayShift.SelectedText;

            Bus_FireOutput.WorkTeamCode = this.uiComboBoxWorkTeam.SelectedText;
            Bus_FireOutput.WorkTeamName = this.uiComboBoxWorkTeam.SelectedText;
            if (Bus_FireOutput.WorkTeamName == "")
            {
                MessageBox.Show("班组不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            //Bus_FireOutput.DepartCode = this.uiTextBox部门1.Text;
            //Bus_FireOutput.DepartName = this.uiTextBox部门名称1.Text;
            if (Bus_FireOutput.DepartName == "")
            {
                MessageBox.Show("部门不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.guid = Guid.Parse(退火原卷guid);
            Bus_FireOutput.OutputGuid = Guid.NewGuid();
            Bus_FireOutput.OutputMaterial = this.uiComboBox新材质.SelectedText;
            Bus_FireOutput.OutputQualityGrade = this.uiComboBox质量等级.SelectedText;
            Bus_FireOutput.OutputQualityInformation = this.uiTextBox质量信息.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputSize = this.uiTextBox新规格.Text;
            Bus_FireOutput.OutputThick = pub.Todecimal(uiTextBox新厚度.Text);
            Bus_FireOutput.OutputWidth = uiTextBox新宽度.Text;
            Bus_FireOutput.OutputWeight = pub.Todecimal(uiTextBox新重量.Text);
            if (Bus_FireOutput.OutputWeight == 0)
            {
                MessageBox.Show("重量不能为0", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.OutputMeter = pub.Todecimal(uiTextBox新米数.Text);
            if (Bus_FireOutput.OutputMeter == 0)
            {
                MessageBox.Show("米数不能为0", "提示", MessageBoxButtons.OK);
                return;
            }
            Bus_FireOutput.InventoryName = this.uiComboBox品名.Text;
            Bus_FireOutput.OutputAddress = this.uiTextBox产地1.Text;
            Bus_FireOutput.Customer = this.uiTextBox客户.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputKangla = this.uiTextBox抗拉.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputQufu = this.uiTextBox屈服.Text.Trim().Replace("--", "");
            Bus_FireOutput.OutputYanshenlv = this.uiTextBox延伸率.Text.Trim().Replace("--", "");
            Bus_FireOutput.FaceDone = this.uiComboBox表面处理.Text.Trim().Replace("--", "");
            Bus_FireOutput.Package = this.uiComboBox包装.Text;

            sql = " insert into Bus_FireOutput(OutputGuid, guid,OutputDate, VolumeCodeNew,Row, OutputVolumeNew, OutputSize, OutputThick, OutputWidth, OutputMaterial, OutputWeight, OutputMeter,";
            sql += " OutputQualityGrade, OutputQualityInformation, OutputEndStatus, OutputNext, PrintTimes, DepartCode, DepartName, ";
            sql += " WorkLineCode, WorkLineName, WorkTeamCode, WorkTeamName, DayShiftCode, DayShiftName, CreateID, Creator,";
            sql += " CreateDate,OutputAddress,Customer,OutputKangla,OutputQufu,OutputYanshenlv,FaceDone,Package,InventoryName,LisuanThick,LisuanMeter,Area)";
            sql += " values(newid(),'" + 退火原卷guid + "','" + Bus_FireOutput.OutputDate?.ToString("yyyy-MM-dd") + "','" + this.uiTextBox原料卷号.Text.Trim().Replace("--", "") + "','" + this.numericUpDown1.Value.ToString() + "','" + 新卷号 + "','" + Bus_FireOutput.OutputSize + "','" + Bus_FireOutput.OutputThick + "','" + Bus_FireOutput.OutputWidth + "',";
            sql += " '" + Bus_FireOutput.OutputMaterial + "','" + Bus_FireOutput.OutputWeight + "','" + Bus_FireOutput.OutputMeter + "','" + Bus_FireOutput.OutputQualityGrade + "','" + Bus_FireOutput.OutputQualityInformation + "',";
            sql += "  '','" + Bus_FireOutput.OutputNext + "',0,'" + Bus_FireOutput.DepartCode + "','" + Bus_FireOutput.DepartName + "',";
            sql += " '" + Bus_FireOutput.WorkLineCode + "','" + Bus_FireOutput.WorkLineName + "','" + Bus_FireOutput.WorkTeamCode + "','" + Bus_FireOutput.WorkTeamName + "',";
            sql += " '" + Bus_FireOutput.DayShiftCode + "','" + Bus_FireOutput.DayShiftName + "','" + pub.sys_user.User_Id + "','" + pub.sys_user.UserTrueName + "',";
            sql += " getdate(),'" + Bus_FireOutput.OutputAddress + "','" + Bus_FireOutput.Customer + "','" + Bus_FireOutput.OutputKangla + "',";
            sql += " '" + Bus_FireOutput.OutputQufu + "','" + Bus_FireOutput.OutputYanshenlv + "','" + Bus_FireOutput.FaceDone + "','" + Bus_FireOutput.Package + "','" + Bus_FireOutput.InventoryName + "','" + uiTextBox理算厚度.Text + "','" + uiTextBox理算米数.Text + "','" + uiTextBox面积.Text.Trim() + "') ";

            if (pub.ExecuteSql(pub.ConnectionString, sql, "单卷退火报工塞入Bus_FireOutput") > 0)
            {
                MessageBox.Show("单卷退火报工成功", "提示", MessageBoxButtons.OK);
                //sql = "update Bus_FireOriginal set IsClosed='Y' , ColseUserId='" + pub.sys_user.User_Id + "',ColseUserName='" + pub.sys_user.UserTrueName + "',CloseDate=getdate() where guid='" + 退火原卷guid + "'";
                //pub.ExecuteSql(pub.ConnectionString, sql, "单卷退火报工成功，自动关闭原卷的状态");
                //显示卷信息到表格上
                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                return;
            }
        }

        private void ListOutput(string 投入卷号)
        {
            卷的总重量 = 0;
            string 查询投入卷号 = "PHY" + 投入卷号.Replace("PHY", "");  //只查卷号的7位纯数字
            string sql;
            sql = "SELECT   OutputGuid, guid, Row, OutputDate 报工日期, OutputVolumeNew 新卷号, OutputSize 新规格, OutputThick 新厚度, OutputWidth 新宽度, OutputMaterial 新材质, OutputWeight 新重量,OutputMeter 新米数,OutputQualityGrade 质量等级, OutputQualityInformation 质量信息, OutputEndStatus 后续状态, OutputNext 去向,";
            sql += " PrintTimes 打印次数, DepartCode 部门编号, DepartName 生产部门,  WorkLineCode 产线编号, WorkLineName 产线, WorkTeamCode 班组编号, WorkTeamName 班组, DayShiftCode 班别编号, DayShiftName 班别, CreateID, Creator 填报人,  CreateDate 填报时间, ModifyID,";
            sql += " Modifier, ModifyDate,Customer 客户,OutputKangla 抗拉,OutputQufu 屈服,OutputYanshenlv 延伸率 ,FaceDone 表面处理,InventoryCode 存货编号,InventoryName 品名,Package 包装 ,area  ";
            sql += " FROM      Bus_FireOutput where   VolumeCodeNew='" + 查询投入卷号 + "' order by OutputVolumeNew ";
            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb != null)
            {
                uiDataGridView产出.AutoGenerateColumns = false;
                this.uiDataGridView产出.DataSource = tb;
                //this.uiDataGridView产出.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                this.uiDataGridView产出.Refresh();
                //产出卷必须连号,不连号不行。
                if (tb.Rows.Count > 0)
                {
                    if (tb.Rows.Count == 1)
                    {
                        卷的总重量 = pub.Todecimal(tb.Rows[0]["新重量"].ToString());
                        //只有一卷
                    }
                    else
                    {
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            卷的总重量 += pub.Todecimal(tb.Rows[i]["新重量"].ToString());

                        }
                    }

                }
            }


            //显示是否关闭了。
            sql = "select IsClosed from [Bus_FireOriginal] where OriginalVolumeNew='" + 投入卷号 + "' ";
            DataTable tb2 = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb2 != null)
            {
                if (tb2.Rows.Count > 0)
                {
                    if (tb2.Rows[0]["IsClosed"].ToString() == "Y")
                    {
                        this.uiLabelIsClosed.Text = "已关闭";
                    }
                    else
                    {
                        this.uiLabelIsClosed.Text = "未关闭";
                    }
                }
            }

        }

        private void Form退火报工维护_FormClosed(object sender, FormClosedEventArgs e)
        {
            删除自己的tempguid的数据(tempguid);
        }
        private void uiDataGridView产出_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.uiDataGridView产出.Rows.Count > 0)
            {

                if (this.uiDataGridView产出.Columns[e.ColumnIndex].Name == "C删除")
                {
                    if (!pub.Is退火报工原始卷被关闭(this.uiTextBox原料卷号.Text))
                    {
                        string 退火产出卷号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString();

                        if (pub.已经抛NC(退火产出卷号) == true)
                        {
                            MessageBox.Show("该卷已经推送NC不可以删除", "提示", MessageBoxButtons.OK);
                            ListOutput(this.uiTextBox原料卷号.Text);
                            return;
                        }

                        string 后续状态 = pub.Get退火产出卷的后续状态(退火产出卷号);
                        if (后续状态 != "未使用")
                        {
                            MessageBox.Show("这个卷状态有问题了", "提示", MessageBoxButtons.OK);
                            //显示卷信息到表格上
                            // this.uiDataGridView产出.Rows[e.RowIndex].Cells["C后续状态"].Value = 后续状态;
                            ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                            return;
                        }
                        else
                        {   //本人才能删除
                            string 填报人 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C填报人"].Value.ToString();
                            if (填报人 != pub.sys_user.UserTrueName)
                            {
                                MessageBox.Show("您不可以删除其他人员填报的数据", "提示", MessageBoxButtons.OK);
                                return;
                            }
                            if (MessageBox.Show("你要删除这个产出卷么?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                //检查是否打印打标签了
                                if (pub.产线可以删除成品卷(退火产出卷号))
                                {
                                    MessageBox.Show("【" + 退火产出卷号 + "】已经打印大标签入库，无法删除");
                                    return;
                                }
                                string sql = "delete Bus_FireOutput where OutputVolumeNew='" + 退火产出卷号 + "';";
                                sql += "delete from Bus_LablePrint where 生产批号 = '" + 退火产出卷号 + "';";
                                pub.ExecuteSql(pub.ConnectionString, sql, "删除产出的退火卷");
                                //原卷的状态还原
                                sql = "update Bus_FireOriginal set IsClosed='N' , ColseUserId=NULL,ColseUserName=NULL,CloseDate=NULL where guid='" + 退火原卷guid + "'";
                                pub.ExecuteSql(pub.ConnectionString, sql, "单卷退火报工取消成功，自动开启原卷的状态");

                                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                            }

                        }
                    }
                    else
                    {
                        MessageBox.Show("已经关闭的投入卷不能删除产出卷信息", "提示", MessageBoxButtons.OK);
                        ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                        return;
                    }
                }
                else if (this.uiDataGridView产出.Columns[e.ColumnIndex].Name == "C打印小标签" && this.uiDataGridView产出.Rows[e.RowIndex].Cells["C去向"].Value.ToString() == "下线入库")
                {
                    
                    Form小标签 form小标签 = new Form小标签();
                    form小标签.生产批号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString();
                    form小标签.规格 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新规格"].Value.ToString();
                    form小标签.钢号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新材质"].Value.ToString();
                    form小标签.等级 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C质量等级"].Value.ToString();
                    form小标签.净重 = Math.Round(pub.Todecimal(this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新重量"].Value.ToString()), 0).ToString();
                    form小标签.工厂编号 = pub.全局工厂编号;
                    form小标签.来源种类 = "退火小标签";
                    form小标签.存货编号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C存货编号"].Value.ToString();
                    form小标签.品名 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C品名"].Value.ToString();
                    form小标签.表面处理 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C表面处理"].Value.ToString(); ;
                    form小标签.表面状态 = "";
                    form小标签.产线名称 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C产线"].Value.ToString(); ;
                    form小标签.执行标准 = this.uiComboBox执行标准.SelectedText;
                    form小标签.长度 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新米数"].Value.ToString(); ; ;
                    form小标签.班组 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C班组"].Value.ToString(); ;
                    //form小标签.锌层 = "普通";
                    form小标签.颜色 = "";
                    form小标签.包装 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C包装"].Value.ToString(); ; ;
                    form小标签.仓库 = this.uiComboBox仓库.SelectedValue.ToString();  ///使用的是编号
                    form小标签.客户 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C客户"].Value.ToString();
                    form小标签.抗拉 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C抗拉"].Value.ToString();
                    form小标签.屈服 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C屈服"].Value.ToString();
                    form小标签.延伸率 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C延伸率"].Value.ToString();
                    form小标签.生产日期 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C报工日期"].Value.ToString();
                    form小标签.ShowDialog(this);
                    ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                }
            }
        }

        private void uiButton关闭_Click(object sender, EventArgs e)
        {
            string sql;
            //产出卷必须连号
            sql = "SELECT   OutputGuid, guid, Row, OutputVolumeNew 新卷号, OutputSize 新规格, OutputThick 新厚度, OutputWidth 新宽度, OutputMaterial 新材质, OutputWeight 新重量, OutputQualityGrade 质量等级, OutputQualityInformation 质量信息, OutputEndStatus 后续状态, OutputNext 去向,";
            sql += " PrintTimes 打印次数, DepartCode 部门编号, DepartName 生产部门,  WorkLineCode 产线编号, WorkLineName 产线, WorkTeamCode 班组编号, WorkTeamName 班组, DayShiftCode 班别编号, DayShiftName 班别, CreateID, Creator 填报人,  CreateDate 填报时间, ModifyID, Modifier, ModifyDate ";
            sql += " FROM      Bus_FireOutput where guid='" + 退火原卷guid + "' order by OutputVolumeNew ";
            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb != null)
            {
                uiDataGridView产出.AutoGenerateColumns = false;
                this.uiDataGridView产出.DataSource = tb;
                //this.uiDataGridView产出.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                this.uiDataGridView产出.Refresh();
                //产出卷必须连号,不连号不行。
                if (tb.Rows.Count > 0)
                {
                    if (tb.Rows.Count == 1)
                    {
                        //只有一卷
                    }
                    else
                    {
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            if (this.uiTextBox前缀.Text + uiTextBox产出卷号.Text + (i + 1).ToString().PadLeft(2, '/') != tb.Rows[i]["新卷号"].ToString())
                            {
                                MessageBox.Show("产出的卷号不连号请检查", "提示", MessageBoxButtons.OK);
                                return;
                            }
                        }
                    }

                }
            }


            if (MessageBox.Show("你要关闭这个投入卷么?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                sql = "update Bus_FireOriginal set IsClosed='Y' , ColseUserId='" + pub.sys_user.User_Id + "',ColseUserName='" + pub.sys_user.UserTrueName + "',CloseDate=getdate() where guid='" + 退火原卷guid + "'";
                pub.ExecuteSql(pub.ConnectionString, sql, "退火手动关闭原卷的状态");
                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
            }
        }

        private void uiTextBox原料卷号_KeyPress(object sender, KeyPressEventArgs e)
        {
            

        }

        private void uiButton搜索已生产卷_Click(object sender, EventArgs e)
        {
            List已生产卷();
        }

        private void List已生产卷()
        {
            用来保存的原卷号 = "";
            //Bus_FireOriginal Bus_FireOriginal = pub.Get退火投入信息(pub.全局工厂编号, this.uiTextBox原料卷号.Text);
            Bus_FireOriginal Bus_FireOriginal = pub.Get退火投入信息(pub.全局工厂编号, this.uiTextBox原料卷号.Text, out 用来保存的原卷号);
            if (Bus_FireOriginal != null)
            {
                this.uiTextBox原料卷号.Text = 用来保存的原卷号;
                退火原卷guid = Bus_FireOriginal.guid.ToString();
                this.uiTextBox产出卷号.Text = pub.去掉前缀(this.uiTextBox原料卷号.Text);//不含前缀，不含后面的串号
                //uiTextBox规格型号1.Text = Bus_FireOriginal.OriginalSize;
                string 厚度 = "";
                string 宽度 = "";
                string 虚拟值 = "";
                pub.FromSize(uiTextBox规格型号1.Text, out 厚度, out 宽度, out 虚拟值);
                this.uiTextBox厚度1.Text = 厚度;
                this.uiTextBox宽度1.Text = 宽度;
                //this.uiTextBox新厚度.Text = 厚度;
                //this.uiTextBox新宽度.Text = 宽度;
                this.uiTextBox卷重量1.Text = Bus_FireOriginal.OriginalWeight.ToString();
                this.uiTextBox材质1.Text = Bus_FireOriginal.OriginalMaterial;
                this.uiTextBox米数.Text = Bus_FireOriginal.OriginalMeter.ToString();
                //this.uiComboBox新材质.Text = this.uiTextBox材质1.Text;
                this.uiTextBox产地1.Text = Bus_FireOriginal.OriginalAddress;
                this.uiTextBox计量单位1.Text = "Kg";
                this.uiTextBox客户.Text = Bus_FireOriginal.Customer;
                ListOutput(用来保存的原卷号);
                塞入自己的tempguid的数据(tempguid, Bus_FireOriginal.OriginalVolumeNew);
            }
            else
            {
                MessageBox.Show("没有投入的卷信息，请先选择投入卷 " + this.uiTextBox原料卷号.Text, "提示", MessageBoxButtons.OK);
                return;
            }
        }

        private void uiButton投入查询_Click(object sender, EventArgs e)
        {
            ListData();
        }

        private void ListData()
        {
            string sql;
            sql = @"SELECT row_number() over(order by  时间,卷号 ) 序号,   工厂编号, 时间, 卷号, 酸洗产出规格, 计划轧制规格,材质, 重量,产地, 米数, 质量等级, 质量信息,成品规格,计划去向  FROM      View_已轧硬未退火 where 1=1  ";
            sql += " and 工厂编号='" + pub.全局工厂编号 + "'";

            //if (this.uiComboBox材质.SelectedText != "全部")
            //{
            //    sql += " and 材质 ='" + this.uiComboBox材质.SelectedText + "'";
            //}
            //if (this.uiTextBox产出规格.Text.Trim() != "")
            //{
            //    sql += " and 酸洗产出规格 ='" + this.uiTextBox产出规格.Text.Trim().Replace("--", "") + "'";
            //}
            //if (this.uiTextBox轧制规格.Text.Trim() != "")
            //{
            //    sql += " and 计划轧制规格 ='" + this.uiTextBox产出规格.Text.Trim().Replace("--", "") + "'";
            //}
            //if (this.uiTextBox成品规格.Text.Trim() != "")
            //{
            //    sql += " and 成品规格 ='" + this.uiTextBox产出规格.Text.Trim().Replace("--", "") + "'";
            //}


            if (this.uiTextBox查询卷号.Text.Trim() != "")
            {
                sql += " and 卷号 like '%" + this.uiTextBox查询卷号.Text.Trim().Replace("--", "") + "%'";
            }




            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb != null && tb.Rows.Count > 0)
            {

                this.uiDataGridView已发未结束.AutoGenerateColumns = false;
                this.uiDataGridView已发未结束.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                this.uiDataGridView已发未结束.DataSource = tb;
                this.uiDataGridView已发未结束.Refresh();
            }
            else
            {
                this.uiDataGridView已发未结束.DataSource = null;
                this.uiDataGridView已发未结束.Refresh();
                MessageBox.Show("没有已轧硬未退火的卷可以选择", "提示", MessageBoxButtons.OK);
                return;

            }


        }

        private void uiTextBox新重量_TextChanged(object sender, EventArgs e)
        {
            刷新理算米数();
            刷新理算厚度();
        }

        private void uiDataGridView可用_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && uiDataGridView可用.Columns[e.ColumnIndex].Name == "D选择")
            {
                this.uiTextBox新重量.Text = "";
                this.uiTextBox新米数.Text = "";
                this.uiTextBox原料卷号.Text = this.uiDataGridView可用.Rows[e.RowIndex].Cells["D卷号"].Value.ToString();
                退火原卷guid = pub.Get退火报工guid(this.uiTextBox原料卷号.Text);
                List已生产卷();
            }
        }

        private void uiDataGridView已发未结束_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && uiDataGridView已发未结束.Columns[e.ColumnIndex].Name == "C选择")
            {
                this.uiTextBox新重量.Text = "";
                this.uiTextBox新米数.Text = "";
                uiTextBox抗拉.Text = "";
                uiTextBox屈服.Text = "";
                uiTextBox延伸率.Text = "";
                this.uiTextBox原料卷号.Text = this.uiDataGridView已发未结束.Rows[e.RowIndex].Cells["C卷号"].Value.ToString();
                //查询退火计划的成品规格，如果计划没有就查轧硬成品规格
                string sql计划成品规格 = @"select ProductSize from Bus_PlanFire
                                    where VolumeCodeNew = '" + uiTextBox原料卷号.Text + "' ";
                DataTable dt计划成品规格 = pub.GetDataTable(pub.ConnectionString, sql计划成品规格);
                if (dt计划成品规格 != null && dt计划成品规格.Rows.Count > 0 && string.IsNullOrWhiteSpace(dt计划成品规格.Rows[0][0]?.ToString()) == false)
                {
                    
                    string 成品规格 = dt计划成品规格.Rows[0][0].ToString();
                    uiTextBox新规格.Text = 成品规格;
                    uiTextBox新厚度.Text = 成品规格.Split('*')?[0];
                    uiTextBox成品宽度.Text = 成品规格.Split('*')?[1];
                }
                else
                {
                    if (!string.IsNullOrEmpty(this.uiDataGridView已发未结束.Rows[e.RowIndex].Cells["C成品规格"].Value.ToString()))
                    {
                        string 成品规格 = this.uiDataGridView已发未结束.Rows[e.RowIndex].Cells["C成品规格"].Value.ToString();
                        uiTextBox新厚度.Text = 成品规格.Split('*')?[0];
                        uiTextBox成品宽度.Text = 成品规格.Split('*')?[1];
                    }

                }
                退火原卷guid = pub.Get退火报工guid(this.uiTextBox原料卷号.Text);
                List已生产卷();
            }
        }

        private void uiComboBox质量等级_SelectedIndexChanged(object sender, EventArgs e)
        {
            pub.List品名(this.uiComboBox品名, FormWorkType, this.uiComboBox质量等级.SelectedText);
        }

        private void uiTextBox新米数_TextChanged(object sender, EventArgs e)
        {
            刷新理算米数();
            刷新理算厚度();
            //计算面积
            decimal 面积 = pub.计算成品面积(uiTextBox新米数.Text.ToString(), uiTextBox成品宽度.Text.ToString());
            uiTextBox面积.Text = 面积.ToString();
        }

        private void uiDataGridView产出_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            //取值
            string 报工日期 = uiDataGridView产出.Rows[e.RowIndex].Cells["C报工日期"].Value.ToString();
            string 新卷号 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString();
            string 新规格 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新规格"].Value.ToString();
            string 新厚度 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新厚度"].Value.ToString();
            string 新宽度 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新宽度"].Value.ToString();
            string 新材质 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新材质"].Value.ToString();
            string 新重量 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新重量"].Value.ToString();
            string 新米数 = uiDataGridView产出.Rows[e.RowIndex].Cells["C新米数"].Value.ToString();
            string 质量等级 = uiDataGridView产出.Rows[e.RowIndex].Cells["C质量等级"].Value.ToString();
            string 质量信息 = uiDataGridView产出.Rows[e.RowIndex].Cells["C质量信息"].Value.ToString();
            string 去向 = uiDataGridView产出.Rows[e.RowIndex].Cells["C去向"].Value.ToString();
            string 产线 = uiDataGridView产出.Rows[e.RowIndex].Cells["C产线"].Value.ToString();
            string 班组 = uiDataGridView产出.Rows[e.RowIndex].Cells["C班组"].Value.ToString();
            string 班别 = uiDataGridView产出.Rows[e.RowIndex].Cells["C班别"].Value.ToString();
            string 客户 = uiDataGridView产出.Rows[e.RowIndex].Cells["C客户"].Value.ToString();
            string 抗拉 = uiDataGridView产出.Rows[e.RowIndex].Cells["C抗拉"].Value.ToString();
            string 屈服 = uiDataGridView产出.Rows[e.RowIndex].Cells["C屈服"].Value.ToString();
            string 延伸率 = uiDataGridView产出.Rows[e.RowIndex].Cells["C延伸率"].Value.ToString();
            string 表面处理 = uiDataGridView产出.Rows[e.RowIndex].Cells["C表面处理"].Value.ToString();
            string 品名 = uiDataGridView产出.Rows[e.RowIndex].Cells["C品名"].Value.ToString();
            string 包装 = uiDataGridView产出.Rows[e.RowIndex].Cells["C包装"].Value.ToString();
            string 填报人 = uiDataGridView产出.Rows[e.RowIndex].Cells["C填报人"].Value.ToString();
            //修改班组班别 修改的班组名称要在数据库里存在
            //string 班组名称 = dgbr.Cells["C班别"].Value.ToString();
            //string 班组编号 = "";
            //string sqlDayShift;
            //sqlDayShift = "SELECT   guid, WorkShopGuid, WorkShopCode, DayShiftCode, DayShiftName, AuditDate, AuditStatus, AuditId, Auditor, Remark,  CreateID, Creator, CreateDate, ModifyID, Modifier, ModifyDate FROM      Dic_DayShift";
            //sqlDayShift += " where WorkShopCode='" + pub.全局工厂编号 + "' and DayShiftName = '" + 班组名称 + "'";
            //DataTable tbDayShift = pub.GetDataTable(pub.ConnectionString, sqlDayShift);
            //if (tbDayShift != null && tbDayShift.Rows.Count > 0)
            //{
            //    班组编号 = tbDayShift.Rows[0]["DayShiftCode"].ToString();
            //}
            //else
            //{
            //    MessageBox.Show("输入的班组不存在，请重新输入，班组有【白班，夜班，中班】", "提示");
            //    return;
            //}
            if (pub.已经抛NC(新卷号) == true)
            {
                MessageBox.Show("该卷已经推送NC不可以修改", "提示", MessageBoxButtons.OK);
                ListOutput(this.uiTextBox原料卷号.Text);
                return;
            }

            //string 表面处理 = dgbr.Cells["C表面处理"].Value.ToString();
            string 后续状态 = pub.Get退火产出卷的后续状态(新卷号);
            if (后续状态 != "未使用")
            {
                MessageBox.Show("这个卷状态:" + 后续状态, "提示", MessageBoxButtons.OK);
                //显示卷信息到表格上
                // this.uiDataGridView产出.Rows[e.RowIndex].Cells["C后续状态"].Value = 后续状态;
                ListOutput(this.uiTextBox原料卷号.Text);
                return;
            }
            else
            {   //本人才能删除Bus_FireOutput

                if (填报人 != pub.sys_user.UserTrueName && pub.sys_user.UserTrueName != "超级管理员")
                {
                    MessageBox.Show("您不可以修改其他人员填报的数据", "提示", MessageBoxButtons.OK);
                    return;
                }
                if (MessageBox.Show("你要修改这个产出卷么？数据需要填正确哦！", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    string sql = @"update bus_FireOutput set OutputDate = '" + 报工日期 + "',OutputSize = '" + 新规格 + "',OutputThick = '" + 新厚度 + "',OutputWidth = '" + 新宽度 +
                                    "',OutputMaterial = '" + 新材质 + "',OutputWeight = '" + 新重量 + "',OutputMeter = '" + 新米数
                                    + "', OutputQualityGrade = '" + 质量等级 + "',OutputQualityInformation = '" + 质量信息 + "',OutputNext = '" + 去向
                                    + "',Customer = '" + 客户 + "',OutputKangla = '" + 抗拉 + "',OutputQufu = '" + 屈服
                                    + "',OutputYanshenlv = '" + 延伸率 + "',FaceDone = '" + 表面处理 + "',InventoryName = '" + 品名 + "',Package = '" + 包装
                                    + "' where  OutputVolumeNew='" + 新卷号 + "'";
                    if (pub.ExecuteSql(pub.ConnectionString, sql, "修改产出的退火卷") > 0)
                    {
                        MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK);
                    }
                }

            }
        }

        private void uiTextBox成品宽度_TextChanged(object sender, EventArgs e)
        {
            //计算面积
            decimal 面积 = pub.计算成品面积(uiTextBox新米数.Text.ToString(), uiTextBox成品宽度.Text.ToString());
            uiTextBox面积.Text = 面积.ToString();
            SetSize();

        }
    }
}
